<template>
  <el-dialog title="[条码扫描]" :visible.sync="visible" width="30%" :before-close="handleClose" append-to-body :show-close="false">
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <!-- <span>这是一段信息</span> -->
    <el-row class="bg-row">
      <el-form label-width="80px">
        <el-form-item label="商品条码">
          <el-input v-model="barcode" @keyup.enter.native="goodsSearchBybarcode"></el-input>
        </el-form-item>
      </el-form>
    </el-row>


  </el-dialog>
</template>

<script>
  import { getGoodsInfoByGoodsBarcode } from '@/api/eims/storage'
  export default {
    props: ["data"],
      data() {
        return {
          visible: false,
          barcode: '',
          stockId: ''
        };
      },
      methods: {
        init(data) {
          this.visible = true
          this.stockId = data
          this.barcode = ''
        },
        goodsSearchBybarcode() {
          let data ={
            goodsBarcode: this.barcode,
            stockId: this.stockId
          }
          getGoodsInfoByGoodsBarcode(data).then(response => {
            if(response.data.code == '0'){
              let resposneData = response.data.data
              resposneData.goodsCode = resposneData.code
              resposneData.goodsBarcode = resposneData.barcode
              resposneData.storageQuantity = resposneData.quantity

              this.visible = false
              this.$emit('refreshData',resposneData)
            }else{
              this.$message.error(response.data.msg)
            }

          })
        },
        handleClose(done){
          done()
        }
      }
    }
</script>

<style lang="scss">
  .el-dialog__header {
    background-color: #78bff1
  }
  .my-autocomplete {
    li {
      line-height: normal;
      padding: 7px;

      .name {
        text-overflow: ellipsis;
        overflow: hidden;
      }
      .addr {
        font-size: 12px;
        color: #b4b4b4;
      }

      .highlighted .addr {
        color: #ddd;
      }
    }
  }

</style>
